package data;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.ResourceBundle;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.Mongo;
import com.mongodb.MongoException;

public class Data {
	static Mongo m = null;

	public static DBCollection data(String name) throws IOException {
		ResourceBundle resource = ResourceBundle.getBundle("config");
		if (m == null) {
			try {
				m = new Mongo(resource.getString("host"));
			} catch (UnknownHostException e) {
				e.printStackTrace();
			} catch (MongoException e) {
				e.printStackTrace();
			}
		}
		DB db = m.getDB(resource.getString("database"));

		DBCollection coll = db.getCollection(name);
		return coll;
	}
}
